{% extends "base.html" %}

{% block header%}
<title>任务日志</title>
{% endblock %}

{% block content %}
{#{% with model_name='Project' url_prefix='/pack/project/project' %}#}
{#<div class="bar">#}
{#	<a>任务日志</a> -> 任务日志展示#}
{#	<div class="buttons">#}
{#		<a  class="btn btn-app btn-grey btn-xs radius-4 pull-right submit"  />保存</a>#}
{#	</div>#}
{#</div>#}

<form>
	<table class="form2">
        <tr>
            <td>
                日志详情： <label><input type="checkbox" id="auto" /> 自动刷新</label>
            </td>
        </tr>
        <tr>
            <td>
                <textarea id="log_area" style="width: 600px; height: 400px;"></textarea>
            </td>
        </tr>
    </table>
</form>
{% if log_url %}
    <script>
    $(function(){
        function async_message(){
            var log_url = "{{log_url}}";
            var option = {
                url: log_url,
                type: "GET",
                data: {type: 0},
                success: function(reps){
                    if(reps.length > 0){
                        $("#log_area").val(reps)
                    }
                },
                timeout: 30000,
                error: function(){
                    console.log(log_url, "请求失败！")
                }
            };
            $.ajax(option);
        }

        var interval = null;
        $("#auto").click(function() {
            if ($("#auto").is(":checked")) {
                interval = setInterval(async_message, 3000);
            } else {
                clearInterval(interval);
            }
        });
        async_message();
    });
    </script>
{% endif %}
{#{% endwith %}#}
{% endblock %}